package sis.ra.relationExtraction;

import java.util.ArrayList;
import java.util.HashMap;

import sis.ra.utility.Utils;


public class CompanyProductRelation {

	public static HashMap<String, ArrayList<String>> getCompanyProducts()
	{
		String file="C:\\Documents and Settings\\I820753\\Desktop\\dataset\\products.txt";
		String content=Utils.readFile(file);
//		System.out.println(content);
		String [] lines=content.split("\n");
		HashMap<String, ArrayList<String>> yahooresult=new HashMap<String, ArrayList<String>> ();
		
		for (int i=0;i<lines.length;i++)
		{
			String [] items=lines[i].split("\t");
			
			String company=items[0];
			ArrayList<String> productslist=new ArrayList<String> ();
			String products="";
			if (items.length>2) products=items[2];
		//	System.out.println(company+" "+products);
			if (products.contains(";"))
			{
				String[] itempro=products.split(" ; ");
				for (int j=0;j<itempro.length;j++)
				{
					if (itempro[j].length()<1) continue;
					if (productslist.contains(itempro[j])) continue;
					productslist.add(itempro[j]);
				}
			}
			System.out.println(company);
			yahooresult.put(company, productslist);
		}
		return yahooresult;
	}
	public static void main(String[] args) {
		HashMap<String, ArrayList<String>> companyproducts=getCompanyProducts();
		System.out.println(companyproducts.size());
	}
}
